﻿namespace BadHabit.Factory.Reports
{
    public class TailReport : Report
    {
        /// <summary>
        /// Implements a Report class to generate a backlog report.
        /// </summary>
        /// <param name="factory"></param>
        public TailReport(FactoryLogic factory) 
            : base(factory) 
        { 
        }

        /// <summary>
        /// The template type name.
        /// </summary>
        public override string TemplateTypeName
        {
            get
            {
                return "TailReport";
            }
        }

        /// <summary>
        /// Adjusts the dataset for XPS render.
        /// </summary>
        /// <param name="projectUId">The projectUId</param>
        /// <returns>The adjusted dataset</returns>
        public override System.Data.DataSet CreateDataSet()
        {
            Data.ProjectDataSet ds = factory.RetriveProject(ProjectUId);
            if (ds.Project.Count > 0)
            {
                ////ProjectUId = ds.Project[0].ProjectUId;
                ProjectCategory = ds.Project[0].Category;
            }

            return ds;
        }

        public override System.Data.DataSet AdjustDataSet(System.Data.DataSet report)
        {
            report = base.AdjustDataSet(report);

            Data.TaskDataSet task = factory.RetriveTailsByProjectUId(ProjectUId, ProjectCategory);

            task.Merge(factory.RetriveImpactedItemsByProjectUId(ProjectUId));

            report.Merge(task);

            return report;
        }
    }
}
